home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HPAVC
/
HPAVC CD-ROM.iso
/
FNTPAK32.ZIP
/
C.EXE
/
DEMOMOUS.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-08-16
|
7KB
|
205 lines
/**********************************************************************
DemoMous.C Copyright 1994, Rob W. Smetana
Turn Screen Swapping ON if appropriate.
Demonstrate how to use our mouse routines.
Show how to select mouse shapes from a "library" of over 65 shapes.
Demonstrate: rsThereIsAMouse \
rsShowCursor & rsHideCursor ) all in
rsSetTextCursor (3 versions) ) Mouse.Obj
rsButtonPressed /
rsLoadMouseCursor \ all in
Num16Shapes ) LdCursor.Obj
Num8Shapes /
NOTE: All parameters are passed by VALUE -- EXCEPT Row and Column
in rsButtonPressed.
**********************************************************************/
#include <font_pak.h> /* for declarations -- PLEASE READ */
#include <dos.h>
#define ESC '\033'
#define KEYINTR 0x16 /* read keyboard function */
#define GETCHAR 1 /* poll for a keypress */
int Readkey();
/*
Syntax: isthereamouse = RSTHEREISAMOUSE ();
Syntax: buttons = RSBUTTONPRESSED (&MRow, &MCol, TextOrGraphics);
Syntax: RSSHOWCURSOR ();
Syntax: RSHIDECURSOR ();
Syntax: RSLOADMOUSECURSOR (Block, WhichShape, ASCIICode);
Syntax: RSSETTEXTCURSOR (FG, BG, ASCIIChar);
Syntax: RSSETTEXTCURSORC (ASCIIChar);
*/
int main (void)
{
int BackColor, ForeColor, Block, ASCIICode, WhichShape, FontSize;
int Button, MRow, MCol, TextOrGraphics, key, MaxNum16s, MaxNum8s;
int temp;
ForeColor = 14, BackColor = 4; /* mouse cursor shape colors! */
/*
Is a mouse active? RSTHEREISAMOUSE returns yes (-1) or no (0).
*/
temp = RSTHEREISAMOUSE();
if (temp == 0 )
{
printf("\n\n");
printf(" Sorry, this demo requires a mouse be attached and a mouse driver loaded.\n");
return (-99);
}
/*
Display how many mouse cursor shapes?
*/
MaxNum16s = NUM16SHAPES();
MaxNum8s = NUM8SHAPES();
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
printf(" ┌─░░░░░░░░░▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓ Mouse Demo ▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒░░░░░░░░─┐ \n");
printf(" ░│ │ \n");
printf(" ░│ You should be looking at a custom mouse cursor. │ \n");
printf(" ░│ │ \n");
printf(" ░│ This is one of %d 16-point, and %d 8-point mouse shapes Font Pak offers │ \n", MaxNum16s, MaxNum8s);
printf(" ░│ │ \n");
printf(" ░│ │ \n");
printf(" ░│Move the mouse around. Click <LEFT> to go forward, or <RIGHT> to go back. │ \n");
printf(" ░│ │ \n");
printf(" ░│ Press ESCAPE to end this demo. │ \n");
printf(" ░│ │ \n");
printf(" ░└──────────────────────────────────────────────────────────────────────────┘ \n");
printf(" ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ ");
printf("\n\n\n\n\n\n\n");
/*
Load a mouse shape into block 0, remap char 255. Because we're using
block 0, we should be sure we restore the default font. If we don't,
and you re-map, say, char 32, your screen will be a mess.
*/
WhichShape = 1;
Block=0; /* Use block 0 ONLY. If you don't, text may disappear! */
ASCIICode = 255; /* we'll re-map chr 255 */
RSLOADMOUSECURSOR (Block, WhichShape, ASCIICode);
/*
Use ONE of the next 3 rsSetTextCursor routines. Or try them all.
*/
/*
Use positive values to USE the FG/BG colors at the cursor.
RSSETTEXTCURSORC (ASCIICode);
*/
/*
Use negative values to INVERT the FG/BG colors at the cursor.
RSSETTEXTCURSORC (-ASCIICode);
*/
/*
this version lets you SELECT the FG/BG colors of the mouse cursor
*/
RSSETTEXTCURSOR (ForeColor, BackColor, ASCIICode);
/*
Select the block you loaded the mouse shape into. This may not be
necessary if you didn't change this demo and we're using Block 0.
*/
RSWHICHFONTS (Block, Block);
RSSHOWCURSOR ();
/* Set TextOrGraphics = -1 to report GRAPHICS-mode pixel coordinates
= 0 to report TEXT-mode Row/Column coordinates
*/
TextOrGraphics = 0;
Button= 0;
while (key != ESC)
{
key = ReadKey();
Button = RSBUTTONPRESSED (&MRow, &MCol, TextOrGraphics);
switch (Button)
{
case 1:
++ WhichShape;
if (WhichShape > MaxNum16s)
WhichShape = 1;
break;
case 2:
-- WhichShape;
if (WhichShape < 1)
WhichShape = MaxNum16s;
break;
default:;
}
if (Button)
{
/* wait for the button to be released--or we'll move too fast */
while (Button > 0)
{
Button = RSBUTTONPRESSED (&MRow, &MCol, TextOrGraphics);
/* printf (" %d %d ", MRow, MCol); */
}
/* now load the next cursor shape */
RSHIDECURSOR ();
RSLOADMOUSECURSOR (Block, WhichShape, ASCIICode);
RSSHOWCURSOR ();
}
}
RSHIDECURSOR ();
/* 1=Left, 2=Rht, 3=Both 4=Middle */
printf("You pressed ESC with the mouse on on Row %d, Column %d. Last mouse shape: %d\n",MRow, MCol, WhichShape);
/* restore the default font in case you re-mapped, say, char 32 <g> */
FontSize = 16; /* must be 8, 14 or 16 -- or you'll get 14 */
/* use 16 for VGAs; 14 for EGAs */
RSLOADDEFAULT (FontSize, Block);
return(0);
} /* end main */
int ReadKey()
{
int key;
union REGS reg;
reg.h.ah = GETCHAR;
int86 (KEYINTR, ®, ®);
key = reg.h.al;
return (key);
}